package ai.people.netmon.framework.domain.graph.enums;

import ai.people.netmon.framework.domain.graph.edges.*;
import ai.people.netmon.framework.exception.enums.GraphExceptionEnum;
import ai.people.netmon.framework.exception.type.BusinessException;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 图边类型枚举
 *
 * @author zhenglin
 * @date 2022/4/25
 */
public enum GraphEdgeEnum {
    /**
     * 家庭、亲属
     */
    FAMILY("family", FamilyEdge.class),
    /**
     * 同事
     */
    COLLEAGUE("colleague", ColleagueEdge.class),
    /**
     * 同伙
     */
    ACCOMPLICE("accomplice", ColleagueEdge.class),
    /**
     * 同学
     */
    CLASSMATE("classmate", ClassmateEdge.class),
    /**
     * 朋友
     */
    FRIEND("friend", FriendEdge.class),
    /**
     * 通讯录
     */
    MAIL_LIST("mail_list", MailListEdge.class),
    /**
     * 电话通讯
     */
    CALL("call", CallEdge.class),
    /**
     * 手机号
     */
    PHONE_EDGE("phone_edge", PhoneEdge.class),
    /**
     * 车牌
     */
    PLATE_EDGE("plate_edge", PlateEdge.class),
    /**
     * 钱包
     */
    WALLET_EDGE("wallet_edge", WalletEdge.class),
    /**
     * 邮箱
     */
    EMAIL_EDGE("email_edge", EmailEdge.class),
    /**
     * 同源账号
     */
    HOMOLOGY("homology", HomologyEdge.class),
    /**
     * 社交关注
     */
    FOLLOW("follow", FollowEdge.class),
    /**
     * 同群
     */
    SAME_GROUP("same_group", SameGroupEdge.class),
    /**
     * 邮件沟通
     */
    MAIL_COMMUNICATION("mail_communication", MailCommunicationEdge.class),
    /**
     * 电子支付
     */
    DIGITAL_PAYMENT("digital_payment", DigitalPaymentEdge.class),
    /**
     * 关系号
     */
    RELATIONSHIP_ACCOUNT("relationship_account", RelationshipAccountEdge.class),

    /**
     * 空关系
     */
    BLANK("blank", BlankEdge.class),
    /**
     * 同板块
     */
    SAME_SECTION("same_section", BlankEdge.class),

    ;

    public String edgeName;

    public Class aClass;

    GraphEdgeEnum(String edgeName,Class aClass) {
        this.edgeName = edgeName;
        this.aClass = aClass;
    }

    public static List<String> getEdgeNameList() {
        return Arrays.stream(GraphEdgeEnum.values()).map(x -> x.edgeName).collect(Collectors.toList());
    }

    public static Class getEdgeClass(String edgeName) {
        for (GraphEdgeEnum value : GraphEdgeEnum.values()) {
            if (value.edgeName.equals(edgeName)) {
                return value.aClass;
            }
        }
        throw new BusinessException(GraphExceptionEnum.EDGE_NOT_EXISTS);
    }
}
